package com.zhiyin.seal.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhiyin.seal.entity.CompanyEntity;
import com.zhiyin.seal.entity.CompanyUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface CompanyUserDao extends BaseMapper<CompanyUserEntity> {

    Integer insertCompanyUser(@Param("companyUserEntity") CompanyUserEntity companyUserEntity);

    Integer initDepartment(@Param("companyEntity") CompanyEntity companyEntity);

    CompanyUserEntity getLastCompanyUser(@Param("userId") Long userId,@Param("companyId") Long companyId);

    CompanyUserEntity selectCompanyUser(@Param("userId") Long userId,@Param("companyId") Long companyId);

    Integer setDefaultCompany(@Param("companyUserEntity") CompanyUserEntity companyUserEntity);

    Integer switchCompany(@Param("userId") Long userId,@Param("companyId") Long companyId);

    Long selectUserDepartmentId(@Param("companyId") Long companyId,@Param("userId") Long userId);

    List<CompanyUserEntity> getAllUserList(@Param("companyId") Long companyId);

    List<CompanyUserEntity> getCompanyListByUserId(@Param("userId") Long userId);

    List<CompanyUserEntity> getUserListByCompanyId(@Param("companyId") Long companyId);

    List<CompanyUserEntity> getUserListByDepartmentId(@Param("departmentId") Long departmentId);

    List<CompanyUserEntity> selectUserListByIdsAndCompanyId(@Param("userIdList") List<Long> userIdList,@Param("companyId") Long companyId);

    Integer updateUserDepartmentUp(@Param("userId") Long id,@Param("departmentId") Long departmentId,@Param("companyId") Long companyId);

    Integer updateUserDepartmentDown(@Param("userId") Long id,@Param("departmentId") Long departmentId,@Param("companyId") Long companyId);

    Integer updateUserAlias(@Param("userId") Long userId,@Param("companyId") Long companyId,@Param("userAlias") String userAlias);

    Integer removeUser(@Param("userId") Long userId,@Param("companyId") Long companyId);

    Integer deleteCompanyUser(@Param("companyId") Long companyId);
}
